package com.xm.nacos;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
@Slf4j
public class ConfigController {
    @Value("${app:config}")
    private String appConfig;

    @Value("${app.config}")
    private String appConfig2;

    @RequestMapping("/config")
    @ResponseBody
    public String getConfig() {
        log.info("appConfig: {}", appConfig);
        return appConfig;// 返回config
    }

    @RequestMapping("/config2")
    @ResponseBody
    public String getConfig2() {
        log.info("appConfig2: {}", appConfig2);
        return appConfig2;// 返回Hello from Nacos Config!
    }
}
